<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      function Animate(name) {
        this.name = name;
        this.sleep = function () {
          console.log(`${this.name}正在睡觉`);
        };
      }

      Animate.prototype.eat = function () {
        console.log(`${this.name}正在吃饭`);
      };

      function Cat(name) {
        Animate.call(this, name);
        this.name = name;
      }
      /*
            文章链接 ==> https://www.zhihu.com/question/288731248/answer/1951122822?utm_source=wechat_session&utm_medium=social&utm_oi=1330604571819950080&utm_content=group2_Answer&utm_campaign=shareopn
            1. 原型连继承 
            Cat.propotype = new Animate("猫1")
            2. 调用父，改变this指向
            3. 组合继承（2，1）
            4. 寄生继承（2，Object.create,prototype.constructor）
            5. 变形4
            6. ES6 class extends
        */
      Cat.prototype = Object.create(Animate.prototype);
      Cat.prototype.constructor = Animate;

      const c = new Cat('猫12');
      console.log(c);
    </script>
  </body>
</html>
